Skip to content

✨ FontAwesome v6 roles, CDN config, fontawesome5 LaTeX support#285

Merged
chrisjsewell merged 1 commit into
mainfrom
brief/13-fontawesome
Jul 15, 2026
Merged

✨ FontAwesome v6 roles, CDN config, fontawesome5 LaTeX support#285
chrisjsewell merged 1 commit into
mainfrom
brief/13-fontawesome

Conversation

@chrisjsewell

@chrisjsewell chrisjsewell commented Jul 14, 2026

Copy link
Copy Markdown
Member

Modernizes the FontAwesome integration around three declarative config options.

Changes

  • v6 roles: fa-solid / fa-brands / fa-regular, emitting exactly those classes. Purely additive: the concise fa/fas/fab/far roles are equally supported, unchanged, with no plans to remove them — the docs present both spellings as first-class, noting the fa-* names are only required for FontAwesome v6+ setups that drop the compatibility aliases (most notably Pro kits, the FontAwesome import interfering with Pro License #174 failure mode), since the role name is emitted verbatim as the CSS class.
  • sd_fontawesome_source ("none" default / "cdn") + sd_fontawesome_cdn_url: opt-in CDN loading via app.add_css_file, replacing the docs' copy-paste html_css_files instruction. The docs now dogfood it.
  • sd_fontawesome_latex grows string values while keeping True/False working (True"fontawesome", output verified byte-identical to main): "fontawesome5" loads fontawesome5.sty and emits \faIcon{name} / \faIcon[regular]{name} (brands resolve by bare name — mapping independently verified against the package's completion data). This resolves the Latex build broken in Sphinx 8 #242 class of clash: if your theme loads fontawesome5, set the same value so both agree. The stored value stays raw (TOML-round-trippable); normalization is a computed property.
  • Per-icon "not included in output" warnings now fire once per build (once=True, verified on the 7.2 floor).
  • Docs: FA section rewritten around the config, with an explicit Pro-kits subsection, the both-spellings-supported note, the LaTeX value table, and a caveat that the LaTeX packages resolve FA5-era icon names (v6-renamed icons render in HTML but not in PDF).

Verification

  • Independent review: no correctness findings. Verified empirically: incremental rebuilds propagate config flips to unrebuilt pages (rebuild="env"); absolute CDN URLs are emitted verbatim (no ?v= mangling, no copy attempt) on 7.2.6 and 9.x; epub with "cdn" behaves identically to the pre-existing html_css_files approach; bool|str confval type-checking clean across the range; no duplicate CDN link in the dogfooding docs build.
  • Legacy parity locked by test: sd_fontawesome_latex = True produces the same \usepackage{fontawesome} + \faicon{...} output as main.
  • Full suite on pinned Sphinx 7.2.6 / 7.4.7 / 8.2.3 (184 passed each; 204 on the post-👌 Sync tabs via change events, open on URL hash, persist choice #284 rebase); new tests/test_fontawesome.py covers roles, CDN link exactly-once/absent, both LaTeX packages, and once-per-build warnings.

Closes #174
Closes #242

@chrisjsewell chrisjsewell force-pushed the brief/13-fontawesome branch from 7c47e9f to d53f19b Compare July 14, 2026 16:33
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.58%. Comparing base (a12b0dc) to head (26d9aba).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #285      +/-   ##
==========================================
+ Coverage   90.87%   91.58%   +0.70%     
==========================================
  Files          13       13              
  Lines        1227     1271      +44     
==========================================
+ Hits         1115     1164      +49     
+ Misses        112      107       -5     
Flag Coverage Δ
pytests 91.58% <100.00%> (+0.70%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chrisjsewell chrisjsewell force-pushed the brief/13-fontawesome branch from d53f19b to 2c7a2d2 Compare July 14, 2026 22:28
- add v6 roles fa-solid/fa-brands/fa-regular (legacy fa/fas/fab/far kept)
- add sd_fontawesome_source ("none"|"cdn") and sd_fontawesome_cdn_url config
- sd_fontawesome_latex now accepts "none"/"fontawesome"/"fontawesome5"
  (bool True/False still work identically); "fontawesome5" emits \faIcon{...}
- throttle the LaTeX / unsupported-builder icon warnings to once per build

Closes #174, #242.
@chrisjsewell chrisjsewell force-pushed the brief/13-fontawesome branch from 2c7a2d2 to 26d9aba Compare July 15, 2026 08:04
@chrisjsewell chrisjsewell merged commit 3a88a18 into main Jul 15, 2026
25 checks passed
@chrisjsewell chrisjsewell deleted the brief/13-fontawesome branch July 15, 2026 08:16
chrisjsewell added a commit that referenced this pull request Jul 15, 2026
Decouples FontAwesome role names from the CSS class scheme they emit, so
users never touch their documents when changing FA versions — the
follow-up agreed in #285's review discussion.

## Design

New TOML-representable option:

```python
sd_fontawesome_version = "as-named"   # or "4" | "5" | "6"
```

- **`"as-named"`** (default): today's exact behaviour — the role name is
emitted verbatim as the leading class. Byte-parity with main proven by
sha256 over a build exercising all seven role spellings.
- **A version value**: any role spelling becomes a pure *style* selector
and emits that version's class scheme — `:fas:`rocket`` and
`:fa-solid:`rocket`` both produce `fa-solid fa-rocket` under `"6"`, `fas
fa-rocket` under `"5"`, `fa fa-rocket` under `"4"` (v4 had no style
prefixes; bare `fa` maps to solid under 5/6). Upgrading FontAwesome is
then a one-line conf.py change; with `"6"`, the concise spellings also
work with Pro kits.
- **LaTeX output is fully version-independent**: the semantic style now
travels on the node (`icon_style` attribute), so `fontawesome5`
rendering (`\faIcon[regular]{…}` etc.) is identical for every version
value — including `"4"`, whose HTML-side style collapse no longer leaks
into PDFs (a review finding, fixed by storing the style rather than
re-deriving it from the emitted class).
- Docs lead with the version-agnostic story; the icon-*name* churn
caveat stays (renames across FA versions are emitted as written, HTML
and LaTeX alike).

## Verification

- Independent review (merge-safe): as-named byte-parity independently
reproduced (identical sha256 across main / branch-default /
branch-explicit, HTML and `.tex`); config flip verified to re-read all
documents on incremental builds (`rebuild="env"` — parse-time class
baking is safe); extra-classes microsyntax preserved under translation;
nested contexts (buttons/cards/dropdowns) clean; parallel `-j4` reads
consistent; invalid value warns and falls back.
- LaTeX invariance now locked by a test parametrized over **all four**
version values.
- Full suite on pinned Sphinx 7.2.6 / 7.4.7 / 8.2.3 (246–249 passed per
revision); the only fixture change is the `icon_style` attribute
appearing on `fontawesome` nodes (audited).

Follow-up to #285 / #174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Latex build broken in Sphinx 8 FontAwesome import interfering with Pro License

1 participant